package mvn12.model;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component("noteUser")
@Scope("prototype")
public class User {
	
	public User() {}
	
	public User(String username) {
		this.name =username;
	}
	
	public User(String username,Address myAddress) {
		this.name =username;
		this.address = myAddress;
	}
		
	//属性，变量，字段
	@Value("${myuser.name}")
	private String name;
	//@Autowired  //按照类型注入
	//@Qualifier("noteAddress") //切换设置对象名字的方式注入
	@Resource(name="noteAddress") //按照名字进行注入
	private Address address;
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void showInfo() {
		System.out.println("学生的名字："+this.name);
		System.out.println("学生的城市："+this.address.getCity());
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

}
